package com.ruoyi.framework.web.service;


import com.ruoyi.common.constant.DeviceConstants;
import com.ruoyi.common.constant.LoginConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.YxDeviceNoticeMessageVo;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.YxAndroidApplication;
import com.ruoyi.system.domain.YxDeviceNoticeMessage;
import com.ruoyi.system.domain.YxFeedback;
import com.ruoyi.system.domain.YxUserAndDevice;
import com.ruoyi.system.service.*;
import com.ruoyi.system.service.impl.SysUserServiceImpl;
import org.apache.http.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 设备通知栏消息服务类
 */
@Component
public class FeedBackService {

    private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);


    @Autowired
    private RedisCache redisUtil;

    @Autowired
    private IYxFeedbackService yxFeedbackService;



    public R<String> uploadFeedBack(String content){

        if(TextUtils.isEmpty(content)){
            return R.fail("content 不可为空");
        }
        //获取当前登录用户
        SysUser user = SecurityUtils.getLoginUser().getUser();

        if(user == null || user.getAccountType() != LoginConstants.USER_TYPE_WX){
            return R.fail("用户信息异常");
        }

        YxFeedback yxFeedback = new YxFeedback();
        yxFeedback.setContent(content);
        yxFeedback.setStatus(0l);
        yxFeedback.setUserId(user.getUserId());
        yxFeedback.setCreateTime(new Date());
        yxFeedbackService.insertYxFeedback(yxFeedback);

        return R.ok();
    }

}
